package com.gitee.huxing.course.conc.conc02.threadpool;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc.conc02.threadpool
 * @ClassName: ExecutorServiceDemo
 * @Author: huxing
 * @DateTime: 2021-08-25 下午4:24
 */
public class ExecutorServiceDemo {

    public static void main(String[] args) {

        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(16);

        try {
            String str = executorService.submit(new Callable<String>(){
                @Override
                public String call() throws Exception {
                    return "I am a task, which submited by the so called laoda, and run by those anonymous workers";
                }
            }).get();
            System.out.println("str =" +str);
        } catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
